import lejos.nxt.*;
import lejos.nxt.comm.*;
import java.io.*;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Fredrik
 */
public class BT {
    
    BTConnection btc;
    DataInputStream dis;
    //DataOutputStream dos;

    public void BTConnect() throws Exception {
        this.btc = Bluetooth.waitForConnection();
        this.dis = this.btc.openDataInputStream();
       // this.dos = this.btc.openDataOutputStream();
    }
    
    public boolean isConnected() {
        if(this.btc == null) {
            return false;
        } else {
            return true;
        }
    }
    
    public void BTClose() throws Exception { //TODO: catch the IOException?
        this.dis.close();
        //this.dos.close();
        Thread.sleep(100);
        this.btc.close();
    }
    
    public String getInputStream() throws Exception {
        String inputStr = "none";
        inputStr = this.dis.readLine();
        return inputStr;
    }
    
}
